package com.chen.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

//分类实体类
public class Type {

    private Integer type_id; //类型id自增
    private String type_name; //类型名
    private String description; //类型描述
    private Date create_time;  //创建时间


    public Type(Integer type_id, String type_name, String description, Date create_time) {
        this.type_id = type_id;
        this.type_name = type_name;
        this.description = description;
        this.create_time = create_time;
    }

    public Type() {
    }

    public Integer getType_id() {
        return type_id;
    }

    public void setType_id(Integer type_id) {
        this.type_id = type_id;
    }

    public String getType_name() {
        return type_name;
    }

    public void setType_name(String type_name) {
        this.type_name = type_name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        //时间转化。数据库CST 时间格式转 Date
        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sim.format(create_time);
        Date newDate=null;
        try {
            newDate = sim.parse(format);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        assert newDate != null;
        java.sql.Date resultDate = new java.sql.Date(newDate.getTime());
        this.create_time = resultDate;
    }

    @Override
    public String toString() {
        return "Type{" +
                "type_id=" + type_id +
                ", type_name='" + type_name + '\'' +
                ", description='" + description + '\'' +
                ", create_time=" + create_time +
                '}';
    }
}
